package com.example.assign2_list;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TimePicker;

public class Alarm extends Activity{
	private int data;
	private boolean isCancel;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.alarm_activity);
        
        /*	Get information form parent	*/
        Intent parentData = getIntent();
        data = parentData.getExtras().getInt("alarm", 1);
    }
	
	public void alarmSet(View v){
		TimePicker timePick = (TimePicker) findViewById(R.id.alarm_timepicker);
		int hour = timePick.getCurrentHour();
		int min = timePick.getCurrentMinute();
		isCancel = false;
		
		int alarmnr = data;
		
		/*	Send extra data back to parent SetAlarms	*/
		Intent intent = new Intent();
		intent.putExtra("alarmnr", alarmnr);
		intent.putExtra("hour", hour);
		intent.putExtra("minute", min);
		intent.putExtra("isCancel", isCancel);
		setResult(RESULT_OK, intent);
		finish();
	}
	
	public void alarmCancel(View v){
		isCancel = true;
		Intent intent = new Intent();
		intent.putExtra("alarmnr", data);
		intent.putExtra("isCancel", isCancel);
		setResult(RESULT_OK, intent);
		finish();
	}
}